package com.hyfrogx.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hyfrogx.common.exception.MyException;
import com.hyfrogx.modules.app.dao.IntegralConfigDao;
import com.hyfrogx.modules.sign.entity.IntegralConfig;
import com.hyfrogx.modules.app.service.IntegralConfigService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @version 1.0.0
 * @Author: lfh
 * @Date: 2019/10/23 9:45
 * @Company 汉咏科技
 */
@Service
public class IntegralConfigServiceImpl extends ServiceImpl<IntegralConfigDao, IntegralConfig> implements IntegralConfigService {

    @Override
    public IntegralConfig getConfig(IntegralConfig config){
        IntegralConfig result = this.baseMapper.getByConfig(config);
        return result;
    }



    @Override
    public Integer getObjectByType(Integer type){
        // TODO Auto-generated method stub
        IntegralConfig integralConfig = this.baseMapper.getObjectByType(type);
        if(integralConfig !=null){
            return integralConfig.getRuleGrade();
        }else{
            throw new MyException("积分赠送规则错误");
        }
    }

    @Override
    public void updateGrade(List<IntegralConfig> meetPricesList) throws Exception{
        this.baseMapper.updateGrade(meetPricesList);
    }

    @Override
    public List<IntegralConfig> getSignIconList() {
        return this.baseMapper.getSignIconList();
    }

}
